//
//  STUserHeaderView.m
//  赛拓
//
//  Created by 王磊 on 8/14/16.
//  Copyright © 2016 立金所. All rights reserved.
//

#import "STUserHeaderView.h"
#import "STTitleView.h"
@interface STUserHeaderView()<STBaseViewDelegate>
@property (nonatomic ,strong) STTitleView *titleView;
@end
@implementation STUserHeaderView
- (STTitleView *)titleView {
    if (!_titleView) {
        
        _titleView = [STTitleView instance];
    }
    return _titleView;
}

- (void)commitInit {
    [super commitInit];
    
    self.titleView.mDelegate = self;
    
    [self addSubview:self.titleView];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapTriggered)];
    
    [self addGestureRecognizer:tap];
}
- (void)updateHeaderData:(id)headerData andTitleData:(id)titleData {
    
    if (!headerData) {
        
        self.titleView.titles = titleData;
    }
}
- (void)updateHeaderData:(id)data {
    
    
}

- (void)updateTitleData:(id)data forIndex:(NSInteger)index {
    
    
}
- (void)layoutSubviews {
    [super layoutSubviews];
    self.titleView.frame = CGRectMake(0, 0, ST_SCREEN_WIDTH, 100 * ST_RATE);
}

- (void)tapTriggered {
    
    [self.mDelegate onItemClick:STItemClickTypeItemTableHead withData:nil forIndexPath:nil];
    
}
- (void)onItemClick:(STItemClickType)itemType withData:(id)data forIndexPath:(NSIndexPath *)indexPath {
    
    [self.mDelegate onItemClick:STItemClickTypeTitle withData:data forIndexPath:indexPath];
}
@end
